<template>
  <div>
    <h2>{{counter}}</h2>
    <button @click="increment">counter++</button>
  </div>
</template>

<script>
import { onMounted , onUpdated , onUnmounted, ref} from "vue";

export default {
  setup(){
    const counter = ref(0);
    const increment = () => {
      counter.value++;
    }

    //挂载
    onMounted(() => {
      console.log("Mounted")
    })
    //更 新
    onUpdated(() => {
      console.log("Updated")
    })
    //卸载
    onUnmounted(() => {
      console.log("Unmounted")
    })
    
    return{
      counter,
      increment
    }
  }
}
</script>

<style scoped>

</style>